package com.getpebble.android.framework.protocol.inbound;

import com.getpebble.android.bluetooth.protocol.ProtocolMessage;
import com.getpebble.android.common.core.util.ObjectUtil;
import com.getpebble.android.common.model.AppVersion;
import com.getpebble.android.framework.protocol.inbound.PblInboundAppInstallMessage.AppInstallResponseType;
import com.getpebble.android.framework.util.ByteUtils;
import com.google.common.primitives.UnsignedInteger;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

public class PblInboundAppBankInfoInstallMessage extends PblInboundAppInstallMessage {
    private static final String TAG = PblInboundAppBankInfoInstallMessage.class.getSimpleName();
    private List<BankInfoEntry> mEntryList = new ArrayList(this.mOccupiedBanks);
    private int mNumberOfBanks;
    private int mOccupiedBanks;

    public static class BankInfoEntry {
        private String mAppName;
        private int mBankNumber;
        private String mCompanyName;
        private UnsignedInteger mFlags;
        private int mInstallId;
        private AppVersion mVersionNumber;

        public int getInstallId() {
            return this.mInstallId;
        }

        public void setInstallId(int installId) {
            this.mInstallId = installId;
        }

        public int getBankNumber() {
            return this.mBankNumber;
        }

        public void setBankNumber(int bankNumber) {
            this.mBankNumber = bankNumber;
        }

        public String getAppName() {
            return this.mAppName;
        }

        public void setAppName(String appName) {
            this.mAppName = appName;
        }

        public String getCompanyName() {
            return this.mCompanyName;
        }

        public void setCompanyName(String companyName) {
            this.mCompanyName = companyName;
        }

        public UnsignedInteger getFlags() {
            return this.mFlags;
        }

        public void setFlags(UnsignedInteger flags) {
            this.mFlags = flags;
        }

        public AppVersion getVersionNumber() {
            return this.mVersionNumber;
        }

        public void setVersionNumber(AppVersion versionNumber) {
            this.mVersionNumber = versionNumber;
        }

        public int hashCode() {
            return ((((((((((getInstallId() + 497) * 71) + getBankNumber()) * 71) + getAppName().hashCode()) * 71) + getCompanyName().hashCode()) * 71) + getFlags().hashCode()) * 71) + getVersionNumber().hashCode();
        }

        public boolean equals(Object o) {
            boolean z = true;
            if (o == null) {
                return false;
            }
            if (o == this) {
                return true;
            }
            if (!(o instanceof BankInfoEntry)) {
                return false;
            }
            BankInfoEntry other = (BankInfoEntry) o;
            if (!(getInstallId() == other.getInstallId() && getBankNumber() == other.getBankNumber() && ObjectUtil.nullCheckEquals(getAppName(), other.getAppName()) && ObjectUtil.nullCheckEquals(getCompanyName(), other.getCompanyName()) && ObjectUtil.nullCheckEquals(getFlags(), other.getFlags()) && ObjectUtil.nullCheckEquals(getVersionNumber(), other.getVersionNumber()))) {
                z = false;
            }
            return z;
        }
    }

    public PblInboundAppBankInfoInstallMessage(ProtocolMessage message) {
        super(message);
        ByteBuffer buffer = message.getDataBuffer();
        checkResponseType(buffer.get());
        this.mNumberOfBanks = buffer.getInt();
        this.mOccupiedBanks = buffer.getInt();
        for (int i = 0; i < this.mOccupiedBanks; i++) {
            BankInfoEntry entry = new BankInfoEntry();
            entry.setInstallId(buffer.getInt());
            entry.setBankNumber(buffer.getInt());
            entry.setAppName(ByteUtils.getStringFromBuffer(buffer, 32));
            entry.setCompanyName(ByteUtils.getStringFromBuffer(buffer, 32));
            entry.setFlags(ByteUtils.getUint32FromBuffer(buffer));
            entry.setVersionNumber(new AppVersion(ByteUtils.getUint8FromBuffer(buffer).intValue(), ByteUtils.getUint8FromBuffer(buffer).intValue()));
            this.mEntryList.add(entry);
        }
    }

    public AppInstallResponseType getResponseType() {
        return AppInstallResponseType.APP_BANK_INFO;
    }

    public List<BankInfoEntry> getEntryList() {
        return this.mEntryList;
    }

    protected int getMinSize() {
        return 9;
    }
}
